package cn.stylefeng.guns.modular.business.frequency.cmarea.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.cmarea.service.CmAreaService;
import cn.stylefeng.guns.modular.business.frequency.cmarea.model.param.CmAreaParam;

import javax.annotation.Resource;

/**
 * cm_area 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmAreaController {

    @Resource
    private CmAreaService cmAreaService;

    /**
     * 分页查询cm_area
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmArea/page")
    @BusinessLog(title = "cm_area_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmAreaParam cmAreaParam) {
        return new SuccessResponseData(cmAreaService.page(cmAreaParam));
    }

    /**
     * 获取全部cm_area
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmArea/list")
    @BusinessLog(title = "cm_area_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmAreaParam cmAreaParam) {
        return new SuccessResponseData(cmAreaService.list(cmAreaParam));
    }

    /**
     * 查看详情cm_area
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmArea/detail")
    @BusinessLog(title = "cm_area_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmAreaParam.detail.class) CmAreaParam cmAreaParam) {
        return new SuccessResponseData(cmAreaService.detail(cmAreaParam));
    }

    /**
     * 添加cm_area
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmArea/add")
    @BusinessLog(title = "cm_area_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmAreaParam.add.class) CmAreaParam cmAreaParam) {
        cmAreaService.add(cmAreaParam);
        return new SuccessResponseData();
    }

    /**
     * 删除cm_area
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmArea/delete")
    @BusinessLog(title = "cm_area_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmAreaParam.delete.class) CmAreaParam cmAreaParam) {
        cmAreaService.delete(cmAreaParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑cm_area
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmArea/edit")
    @BusinessLog(title = "cm_area_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmAreaParam.edit.class) CmAreaParam cmAreaParam) {
        cmAreaService.edit(cmAreaParam);
        return new SuccessResponseData();
    }


}
